﻿package net.da.processor.user.impl;

import net.da.processor.AbstractProcessorMock;
import net.da.processor.user.CreateUserProcessor;
import net.da.processor.user.io.CreateUserRequest;
import net.da.processor.user.io.CreateUserResponse;

public class CreateUserProcessorMock extends AbstractProcessorMock<CreateUserResponse, CreateUserRequest> implements CreateUserProcessor {

    @Override
    protected CreateUserResponse process(CreateUserRequest request) {
        CreateUserResponse createUserResponse = new CreateUserResponse();
        createUserResponse.setUserCreatedSuccessfuly(false);
        // Allow user only from this organization unit
        if (!request.getOrganisationUnitName().equals("Лунный свет")) {
            createUserResponse.setUserCreatedSuccessfuly(true);
        }
        // If we already have this user (see login mock)
        if (!(request.getUserName().equals("agent") && request.getPassword().equals("password"))) {
            createUserResponse.setUserCreatedSuccessfuly(true);
        }
        return createUserResponse;
    }

    @Override
    protected CreateUserResponse buildIOResponseEmptyInstance() {
        return new CreateUserResponse();
    }

}
